package com.剑指offer.no53;

public class Solution {
    public int search(int[] nums, int target) {
        int res = 0;
        int left = 0, right = nums.length - 1;

        // 找到最左的值
        while (left < right) {
            int mid = (left + right) / 2;
            if (nums[mid] >= target) {
                right = mid;
            }else {
                left = mid;
            }
        }

        // 开始数数
        while(left < nums.length && nums[left++] == target){
            res ++;
        }
        return res;
    }
}
